﻿namespace RialternativeSample.Client.Northwind
{
    using System;
    using System.Collections.ObjectModel;
    using Microsoft.Windows.Data.DomainServices;
    using RialternativeSample.Client.Northwind.Interfaces;
    using RialternativeSample.Server.NorthwindService;

    public class ProductsDataService : IProductsDataService
    {
        private NorthwindContext context;

        public ProductsDataService(NorthwindContext context)
        {
            this.context = context;
        }

        public void GetProductsAsync(Action<ObservableCollection<Products>> callback)
        {
            this.context.Load(
                this.context.GetProductsQuery(),
                lo => callback(new EntityList<Products>(this.context.Products, lo.Entities)),
                null);
        }
    }
}
